package cmd

import (
	"gitee.com/gtsoa/bsdemo/models"
	"gitee.com/gtsoa/bsdemo/server"
	"gitee.com/gtsoa/mspkg/config"
	"github.com/spf13/cobra"
)

func serveBindConfig(cmd *cobra.Command) {
	config.BindLogConfig(cmd)
	config.BindServerConfig(cmd)
	models.BindConfig(cmd)
}

// serveCmd represents the serve command
var serveCmd = &cobra.Command{
	Use:   "serve",
	Short: "serve bsdemo service",
	Run: func(cmd *cobra.Command, args []string) {
		serveBindConfig(cmd)
		serveRun()
	},
}

func init() {
	rootCmd.AddCommand(serveCmd)
}

func serveRun() {
	cfg := config.ParseLogConfig()
	cfg.Install()

	server.Main()
}
